def is_all_chinese(s):
    for ch in s:
        if not u'\u4e00'<= ch <= u'\u9fff':
            return False
    return True


def parse_fullname(name):
    import pinyin
    rt = {}
    fx = ['欧阳', '太史', '端木', '上官', '司马', '东方', '独孤', '南宫', '万俟', '闻人', '夏侯', '诸葛', '尉迟',
          '公羊', '赫连', '澹台', '皇甫',
          '宗政', '濮阳', '公冶', '太叔', '申屠', '公孙', '慕容', '仲孙', '钟离', '长孙', '宇文', '城池', '司徒',
          '鲜于', '司空', '汝嫣', '闾丘', '子车', '亓官',
          '司寇', '巫马', '公西', '颛孙', '壤驷', '公良', '漆雕', '乐正', '宰父', '谷梁', '拓跋', '夹谷', '轩辕',
          '令狐', '段干', '百里', '呼延', '东郭', '南门',
          '羊舌', '微生', '公户', '公玉', '公仪', '梁丘', '公仲', '公上', '公门', '公山', '公坚', '左丘', '公伯',
          '西门', '公祖', '第五', '公乘', '贯丘', '公皙',
          '南荣', '东里', '东宫', '仲长', '子书', '子桑', '即墨', '达奚', '褚师']
    # 判断是否全中文
    dyz = {
        'pinyin':['shan','ou','zha','xie','cheng','yue',
        'yun','qiu','chong','shao','kui','shen',
        'zhai','piao','po','yun','qu','nai','kan',
        'du','miao','nie','gou','e'],
        'word':['单','区','查','解','晟','乐',
        '贠','仇','种','召','隗','谌',
        '翟','扑','繁','员','瞿','能','阚',
        '都','缪','乜','句','阿']
    }
    if is_all_chinese(name):
        if name[0:2] in fx:
            rt['firstname'] = name[0:2]
            rt['lastname'] = name[2:]
            rt['pinyin'] = pinyin.get(name, format='strip')
            rt['py'] = pinyin.pinyin.get_initial(name, '')
        else:
            rt['firstname'] = name[0:1]
            rt['lastname'] = name[1:]
            npy = ''
            if rt['firstname'] in dyz['word']:
                npy = dyz['pinyin'][dyz['word'].index(rt['firstname'])]
                npy2 = pinyin.get(rt['lastname'], format='strip')
                rt['pinyin'] = npy+npy2
                rt['py'] = npy[0]+pinyin.pinyin.get_initial(rt['lastname'], '')
            else:
                rt['pinyin'] = pinyin.get(name, format='strip')
                rt['py'] = pinyin.pinyin.get_initial(name, '')
    else:
        tmp = name.split()
        rt['firstname'] = tmp[0]
        rt['lastname'] = name.replace(tmp[0], '').strip()
        rt['pinyin'] = name
        rt['py'] = ''
    return rt
